<?php $title='  JS 封装 HTML'; include 'header.php'; ?>
<style type="text/css" media="screen">
    textarea{height:200px;width:46%;}
</style>
<script type="text/javascript" charset="utf-8">
<!-- 
    function rechange(){
        document.getElementById('re').value=document.getElementById('oresult').value.replace(/document.writeln\("/g,"").replace(/"\);/g,"").replace(/\\\"/g,"\"").replace(/\\\'/g,"\'").replace(/\\\//g,"\/").replace(/\\\\/g,"\\")
    }
    function change(){
        document.getElementById('oresult2').value="document.writeln(\""+document.getElementById('osource').value.replace(/\\/g,"\\\\").replace(/\\/g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"").split('\n').join("\");\ndocument.writeln(\"")+"\");"
    } 
-->
</script>
<h2>HTML2JS</h2>
<h3>用javascript封装HTML</h3>
<textarea id="osource" class="HJtxt" onfocus="change()" onkeyup="change()" placeholder="输入html代码" autofocus="autofocus" ></textarea>
<textarea id="oresult2" class="HJtxt" readonly=true placeholder="此处显示转换为javascript输出html的代码"></textarea>
<hr/>
<h3>将javascript输出的内容还原为HTML源码</h3>
<textarea id="oresult" class="HJtxt" onfocus="rechange()" onkeyup="rechange()" placeholder="输入javascript代码"></textarea>
<textarea id="re" class="HJtxt" readonly=true placeholder="此处显示 javascript 输出后显示 的 html的代码"></textarea>
<?php include 'footer.php'; ?>
